package com.quectel.dms.util;

import cn.hutool.system.SystemUtil;
import com.quectel.util.classpath.ClasspathUtils;
import com.quectel.util.common.OSUtils;

import static com.quectel.dms.service.aiotap.ThirdLibrary.AIOTAP_LIB_PATH;

/**
 * 在这里编写说明
 *
 * @author: ryan
 * @email: ryan.ran@quectel.com
 * @date: 2023-08-17 19:09:00
 */
public class LibCopyUtils {


    /**
     * 拷贝动态链接库
     */
    public static void copy() {
        //
        copyAiotap();
    }





    /**
     * 拷贝aiotap
     */
    private static void copyAiotap() {
        if (SystemUtil.getOsInfo().isWindows()) {
            ClasspathUtils.copyFiles(AIOTAP_LIB_PATH,
                    "aiotap/windows/aiotap_sdk.dll"
            );
        } else if (OSUtils.isRedhatRelease()) {
            ClasspathUtils.copyFiles(AIOTAP_LIB_PATH,
                    "aiotap/centos/libaiotap_sdk.so",
                    "aiotap/centos/libcares.so",
                    "aiotap/centos/libcrypto.so.1.0.0",
                    "aiotap/centos/libcrypto_1_0_0.so",
                    "aiotap/centos/libjson_schema_validator.so",
                    "aiotap/centos/libllhttp.so",
                    "aiotap/centos/libmxml.so",
                    "aiotap/centos/libspdlog.so",
                    "aiotap/centos/libssl.so.1.0.0",
                    "aiotap/centos/libssl_1_0_2.so",
                    "aiotap/centos/libtaro.so"
            );
        } else if (OSUtils.isDebianRelease()) {
            ClasspathUtils.copyFiles(AIOTAP_LIB_PATH,
                    "aiotap/ubuntu/libaiotap_sdk.so",
                    "aiotap/ubuntu/libcares.so",
                    "aiotap/ubuntu/libcrypto_1_0_0.so",
                    "aiotap/ubuntu/libjson_schema_validator.so",
                    "aiotap/ubuntu/libllhttp.so",
                    "aiotap/ubuntu/libmxml.so",
                    "aiotap/ubuntu/libspdlog.so",
                    "aiotap/ubuntu/libssl_1_0_2.so",
                    "aiotap/ubuntu/libtaro.so"
            );
        }

    }
}
